/*
 * @Author: byron
 * @Date: 2021-11-11 20:20:30
 * @LastEditTime: 2022-02-11 19:32:41
 */

import { message } from 'ant-design-vue'

const setDocumentTitle = (title) => {
    document.title = `博客后台管理系统 -- ${title}`
}

export const permissionController = async (to, from, next) => {
    const { meta } = to
    setDocumentTitle(meta.title)
    // await store.dispatch('app/execCancelToken')
    // 检 测 登 录
    if (
        !to.fullPath.includes('login') &&
        !sessionStorage.getItem('USER_TOKEN')
    ) {
        message.error('Token过期，请重新登录')
        next({
            path: '/login',
        })
    } else {
        next()
    }
}
